package com.bjesc_b2c.app.appraiset.widget.dialog;

import android.app.Activity;
import android.content.Context;
import android.text.TextUtils;
import android.view.View;

import com.bjesc_b2c.app.appraiset.R;
import com.bjesc_b2c.app.appraiset.widget.BaseDialog;
import com.facebook.drawee.view.SimpleDraweeView;

/**
 * Created by lenovo on 2017/2/24.
 */

public class QRCodeDialog extends BaseDialog implements View.OnClickListener {
    private String codeUrl;

    private SimpleDraweeView frescoQRCode;

    public QRCodeDialog(Context context, String url) {
        super(context);
        this.codeUrl = url;
        initViews();
    }

    private void initViews() {
        view = inflater.inflate(R.layout.dialog_qrcode, null);
        frescoQRCode = (SimpleDraweeView) view.findViewById(R.id.fresco_rqcode);
        view.findViewById(R.id.iv_dismiss).setOnClickListener(this);
        if(!TextUtils.isEmpty(codeUrl)) {
            frescoQRCode.setImageURI(codeUrl);
        }
        setContentView(view);
        show();
    }

    @Override
    public void onClick(View view) {
        if( getContext() instanceof Activity){
            ((Activity) getContext()).finish();
        }
        dismiss();
    }
}
